namespace NFreeMarker.Core
{
    internal sealed class NotExpression : BooleanExpression
    {
        private readonly Expression _target;

        internal NotExpression(Expression target)
        {
            _target = target;
        }

        internal override bool IsTrue(Environment env)
        {
            return (!_target.IsTrue(env));
        }

        public override string GetCanonicalForm()
        {
            return "!" + _target.GetCanonicalForm();
        }

        internal override bool IsLiteral()
        {
            return _target.IsLiteral();
        }

        protected override Expression DeepCloneImpl(string name, Expression subst)
        {
            return new NotExpression(_target.DeepClone(name, subst));
        }
    }
}